package com.example.administrator.myapplication.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

import com.example.administrator.myapplication.R;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

public class NewsActivity extends AppCompatActivity {
 TextView head;
    WebView body;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);
        body= (WebView) findViewById(R.id.body);
        head= (TextView) findViewById(R.id.head);
        String newshead=getIntent().getStringExtra("head");
        String newsbody=getIntent().getStringExtra("body");
        head.setText(newsbody);
        head.setText(newshead);
    }
    public void body_loading(){
        RequestParams params=new RequestParams("http://web.csmzxy.com/netCourse/readData");
        params.addQueryStringParameter("cmd","9");
        params.addQueryStringParameter("v1", String.valueOf(body));
        x.http().get(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                String encoding="UTF-8";
                String mimeType="text/html";
                body.loadDataWithBaseURL("file://",result,mimeType,encoding,"about:blank");
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {

            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }
}
